package trees;

/**
 * Created by Yang on 2017/6/20.
 */
public class Mindepth {

    //* Definition for binary tree
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public int run(TreeNode root) {
        if (root == null) return 0;
        int l = run(root.left);
        int r = run(root.right);
        if (l == 0 || r == 0) return 1 + l + r;
        return 1+(l<r?l:r);
    }
}
